import commonjs from "@rollup/plugin-commonjs"
import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import { terser } from "rollup-plugin-terser";
import postcss from "rollup-plugin-postcss";
import vue from "rollup-plugin-vue";
import replace from "rollup-plugin-replace";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";

export default {
  input: "./src/main.js",
  output: [
    {
      format: "umd",
      name: "yzUtils",
      file: "dist/yz.umd.js",
      globals: {
        "lodash": "_"
      }
    }
  ],
  external: ["lodash"],
  plugins: [
    commonjs(),
    // 如果需要加载第三方库打包到对应文件的话，就需要这个配置
    resolve(),
    replace({
      'process.env.NODE_ENV': JSON.stringify('production')
    }),
    babel({
      babelHelpers: "bundled"
    }),
    postcss(),
    vue(),
    terser(),
    serve({
      open: true,
      port: 8080,
      contentBase: "." // 服务哪个文件夹
    }),
    livereload()
  ]
}
